﻿using System;
using N3P.WCF.Proxyless;
using ServiceContracts;

namespace Example
{
    class Program
    {
        private static WcfClient<IMyInterface> _caller;

        static void Main()
        {
            _caller = new WcfClient<IMyInterface>();
            _caller.Call(x => x.MakeDate(1999, 12, 31), HandleResponse);
            Console.ReadLine();
        }

        private static void HandleResponse(DateTime arg1, Exception arg2)
        {
            if(arg2 != null)
            {
                Console.WriteLine("Exception!");
                Console.WriteLine(arg2);
                _caller.Dispose();
                return;
            }

            Console.WriteLine(arg1.ToShortDateString());
            _caller.Dispose();
        }
    }
}
